import { number_format } from '@/utils/validate'
import http from '../http'

interface RegisterParams {
  mobile: string
  code: string
  password: string
  re_password: string
}
/**
 * 注册
 * @param data
 */
export function register(data: RegisterParams) {
  return http.post('login/register', data)
}
interface MploginParams {
  mobile: string
  password: string
}
/**
 * 密码登录
 * @param data
 */
export function mplogin(data: MploginParams) {
  return http.post('login/mplogin', data)
}
interface McloginParams {
  mobile: string
  code: string
}
/**
 * 验证码登录
 * @param data
 */
export function mclogin(data: McloginParams) {
  return http.post('login/mclogin', data)
}
/**
 * 获取验证码
 * @param phone
 */
export function sendCode(data: string) {
  return http.post('login/sendCode', { mobile: data })
}
/**
 * 找回密码
 * @param phone
 */
export function changePassword(data: RegisterParams) {
  return http.post('login/changePassword', data)
}
/**
 * 401.获取用户信息
 * @param phone
 */
export function getUserInfo() {
  return http.get('user/getUserInfo')
}
/**
 * 402.我的订单列表
 * @param phone
 */
export function getUserOrderList(data: {
  page: number
  page_size: number
  order_status: string | number
}) {
  return http.get('order/getUserOrderList', {
    params: {
      ...data
    }
  })
}

/**
 * 401.获取我的藏品
 * @param phone
 */
export function getAllCollectionMyNumbers(data: {
  page: number
  page_size: number
  user_sale_status: string
  sort_rule: string
  sort_type: string
}) {
  return http.get('collection/getAllCollectionMyNumbers', {
    params: {
      ...data
    }
  })
}
/**
 * 213.我的藏品列表（带数量）
 * @param phone
 */
export function getMymyCollections(data: { page: number; page_size: number }) {
  return http.get('collection/getMyList', {
    params: {
      ...data
    }
  })
}

/**
 * 213.我的单一藏品编号列表
 * @param phone
 */
export function getOneCollectionMyNumbers (data: {
  page: number;
  page_size: number,
  collection_id: string,
  user_sale_status:string,
  sort_rule: string,
  sort_type:string
}) {
  return http.get('collection/getOneCollectionMyNumbers', {
    params: {
      ...data
    }
  })
}


/**
 * 401.408.我的盲盒列表
 * @param phone
 */
export function getMyBoxList(data: { page: number; page_size: number }) {
  return http.get('box/myBoxList', {
    params: {
      ...data
    }
  })
}
/**
 * 409.打开盲盒
 * @param phone
 */
export function openBox(data: { box_number_id: string }) {
  return http.post('box/openBox', data)
}
/**
 *412.获取余额明细列表
 * @param phone
 */
export function getBalanceRecodeList(data: {
  page: number
  page_size: number
}) {
  return http.get('user/getBalanceRecodeList', {
    params: {
      ...data
    }
  })
}
/**
 *412.获取我的钱包列表
 * @param phone
 */
export function getWalletList() {
  return http.get('/user/getWalletList')
}
/**
 *4420.获取我的银行卡列表
 * @param phone
 */
export function getBankCardList() {
  return http.get('/user/getBankCardList')
}
/**
 *421.删除银行卡
 * @param phone
 */
export function delBankCard(data: { account: string }) {
  return http.post('/user/delBankCard', data)
}
/**
 *421.设置默认
 * @param phone
 */
export function setDefaultBankCard(data: { card_id: string }) {
  return http.post('/user/setDefaultBankCard', data)
}
/**
 *421.添加银行卡
 * @param phone
 */
export function addBankCard(data: { account: string }) {
  return http.post('/user/addBankCard', data)
}
/**
 *421.417.设置支付密码
 * @param phone
 */
export function setPayPassword(data: { pay_password: string }) {
  return http.post('/user/setPayPassword', data)
}
/**
 *提现
 * @param
 */
export function apply(data: {
  pay_way: number
  money: string
  bank_card_id: string
}) {
  return http.post('/cashout/apply', data)
}
/**
 *充值
 * @param
 */
export function rechargeBySandH5(data: { money: string; client_ip: string }) {
  return http.post('recharge/rechargeBySandH5', data)
}
/**
 *充值
 * @param
 */
export function createOrderBySandFast(data: { money: string}) {
  return http.post('recharge/createOrderBySandFast', data)
}
/**
 *.获取邀请规则内容+统计数据
 * @param
 */
export function getInviteRuleInfo() {
  return http.get('user/getInviteRuleInfo')
}
/**
 *.424.获取我的邀请记录
 * @param
 */
export function getMyInviteList(data: { page: number; page_size: number }) {
  return http.get('user/getMyInviteList', {
    params: {
      ...data
    }
  })
}
/**
 *.获取平台邀请列表数据
 * @param
 */
export function getInviteList(data: { page: number; page_size: number }) {
  return http.get('user/getInviteList', {
    params: {
      ...data
    }
  })
}
/**
 *.获取平台邀请列表数据
 * @param
 */
export function cancelOrder(data: { order_sn: string }) {
  return http.post('order/cancelOrder', data)
}
/**
 *.410.寄售记录
 * @param
 */
export function consignmentRecord(data: {
  page: number
  page_size: number
  co_status: string | number
}) {
  return http.get('collection/consignmentRecord', {
    params: {
      ...data
    }
  })
}

/**
 *.413.获取合成规则列表
 * @param
 */
export function synthesisRuleList(data: { page: number; page_size: number }) {
  return http.get('user/synthesisRuleList', {
    params: {
      ...data
    }
  })
}
/**
 *.413.414.获取合成详情
 * @param
 */
export function mySynthesisCollection(data: { rule_id: string }) {
  return http.get('user/mySynthesisCollection', {
    params: {
      ...data
    }
  })
}
/**
 *.413.414.获取合成详情
 * @param
 */
export function synthesisRuleDetail(data: { rule_id: string }) {
  return http.get('user/synthesisRuleDetail', {
    params: {
      ...data
    }
  })
}
/**
 *.413.414.获取合成详情
 * @param
 */
export function synthesis(data: { rule_id: string }) {
  return http.post('user/synthesis', data)
}
/**
 *.429.消息列表
 * @param
 */
export function getArticleList(data: {
  page: number
  page_size: number
  type: string
}) {
  return http.get('article/getArticleList', {
    params: {
      ...data
    }
  })
}
/**
 *.430.消息详情
 * @param
 */
export function getArticleDetail(data: { article_id: string }) {
  return http.get('article/getArticleDetail', {
    params: {
      ...data
    }
  })
}
/**
 * 寄售编号
 */
export function consignmentNumber(data: { number_id: string; price: string }) {
  return http.post('collection/consignmentNumber', data)
}

/**
 * 取消寄售
 */
export function cancelConsignmentNumber(data: { number_id: string }) {
  return http.post('collection/cancelConsignmentNumber', data)
}
/**
 * 取消寄售
 */
export function getNoReadArticleNumber() {
  return http.get('article/getNoReadArticleNumber')
}
/**
 * 注销账户
 */
export function cancellationAccount() {
  return http.post('user/cancellationAccount')
}
/**
 * 212.获取作者主页信息
 */
export function getAuthorCollectionList(data: {
  author_id: string
  page: number
  page_size: number
}) {
  return http.get('collection/getAuthorCollectionList', {
    params: {
      ...data
    }
  })
}
/**
 * 上传
 */
export function upload(data: any) {
  return http.request({
    url: 'auxiliary/upload',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
/**
 * 432.实名认证
 */
export function realNameAuthentication(data: {
  id_card: string
  mobile: string
  code: string
  real_name: string
}) {
  return http.post('user/realNameAuthentication', data)
}
/**
 * 432.昵称
 */
export function setUserNickname(data: { nickname: string }) {
  return http.post('user/setUserNickname', data)
}

/**
 *421.417.设置支付密码
 * @param phone
 */
export function setUserAvatar(data: { avatar: string }) {
  return http.post('/user/setUserAvatar', data)
}
